package com.smrtcold.dev.service.base;


import com.smrtcold.dev.config.MqttBase;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * 化霜模式1
 */
@Log4j2
@Service
@RequiredArgsConstructor
public class BaseServer {

    @Value("${spring.mqtt.plcmqsprefix}")
    private String plcmqsprefix;

    private final MqttBase.DevOperation devOperation;



    public boolean push(String topic, String data) {
        try {
            this.devOperation.push(this.plcmqsprefix+topic, data);
            return true;
        } catch (Exception e) {
            log.warn("推送消息失败：{}，内容：{},{}", topic, data, e.getMessage());
        }
        return false;
    }
}
